﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <div class="form-group">
            <label class="col-sm-2 control-label ">Provider<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="provider" col="Provider" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">OpenID<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="openID" col="OpenID" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">NickName<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="nickName" col="NickName" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">AccessToken<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="accessToken" col="AccessToken" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">Expire<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="expire" col="Expire" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">CreateUserID<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="createUserID" col="CreateUserID" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">CreateTime<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="createTime" col="CreateTime" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">UpdateIP<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="updateIP" col="UpdateIP" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">Remark<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="remark" col="Remark" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">UserID<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="userID" col="UserID" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">LinkID<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="linkID" col="LinkID" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">Avatar<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="avatar" col="Avatar" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">RefreshToken<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="refreshToken" col="RefreshToken" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">Enable<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="enable" col="Enable" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">CreateIP<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="createIP" col="CreateIP" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">UpdateUserID<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="updateUserID" col="UpdateUserID" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">UpdateTime<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="updateTime" col="UpdateTime" type="text" class="form-control" />
            </div>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        getForm();

        $('#form').validate({
            rules: {
                provider: { required: true }
            }
        });
    });

    function getForm() {
        if (id > 0) {
            ys.ajax({
                url: '@Url.Content("~/SystemManage/UserConnect/GetFormJson")' + '?id=' + id,
                type: 'get',
                success: function (obj) {
                    if (obj.Tag == 1) {
                        $('#form').setWebControls(obj.Data);
                    }
                }
            });
        }
        else {
            var defaultData = {};
            $('#form').setWebControls(defaultData);
        }
    }

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            ys.ajax({
                url: '@Url.Content("~/SystemManage/UserConnect/SaveFormJson")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }
</script>

